<template>
  <el-container class="layout-container-demo" style="height: 1000px">
    <el-aside width="200px">
      <el-scrollbar>
        <el-menu :default-openeds="['1', '3']">
          <el-sub-menu index="0">
            <template #title>
              <el-icon>
                <House/>
              </el-icon>
              数据台
            </template>
          </el-sub-menu>
          <el-sub-menu index="1">
            <template #title>
              <el-icon>
                <user/>
              </el-icon>
              用户管理
            </template>
            <el-menu-item index="1-1">用户列表</el-menu-item>
            <el-menu-item index="1-2">用户详情</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="2">
            <template #title>
              <el-icon>
                <compass/>
              </el-icon>
              角色管理
            </template>
            <el-menu-item index="2-1">角色列表</el-menu-item>
            <el-menu-item index="2-2">角色详情</el-menu-item>
          </el-sub-menu>
          <el-sub-menu index="3">
            <template #title>
              <el-icon>
                <setting/>
              </el-icon>
              权限管理
            </template>
            <el-menu-item index="3-1">权限列表</el-menu-item>
            <el-menu-item index="3-2">权限详情</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </el-scrollbar>
    </el-aside>

    <el-container>
      <el-header style="text-align: right; font-size: 12px">
        <div class="toolbar">
          <el-dropdown>
            <el-icon style="margin-right: 8px; margin-top: 1px"
            >
              <setting
              />
            </el-icon>
            <template #dropdown>
              <el-dropdown-menu>
                <el-dropdown-item @click="logout">退出登录</el-dropdown-item>
              </el-dropdown-menu>
            </template>
          </el-dropdown>
          <span>admin</span>
        </div>
      </el-header>

      <el-main>
        <el-scrollbar>
          <el-input
              placeholder="请输入内容"
              v-model="input"
              clearable>
          </el-input>
          <el-table
              :data="tableData"
              height="2000"
              border
              style="width: 100%">
            <el-table-column
                prop="name"
                label="昵称"
                width="180"
                align="center">
            </el-table-column>
            <el-table-column
                prop="phone"
                label="电话"
                width="180"
                align="center">
            </el-table-column>
            <el-table-column
                prop="username"
                label="账号"
                align="center">
            </el-table-column>
            <el-table-column
                prop="date"
                label="创建日期"
                align="center">
            </el-table-column>
            <el-table-column
                prop="password"
                label="密码"
                align="center">
            </el-table-column>
            <el-table-column label="操作" align="center" style="width: 50px">
              <el-button
                  size="default"
                  @click="handleEdit" align="center">编辑
              </el-button>
              <el-button
                  size="default"
                  type="danger"
                  @click="handleDelete" align="center">删除
              </el-button>
            </el-table-column>
          </el-table>

        </el-scrollbar>
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import {Menu as Compass, User, Setting, House} from '@element-plus/icons-vue'
import {logOut} from "@/api/sys";
import {useStore} from "vuex";
import {useRouter} from "vue-router";

const store = useStore()
const router = useRouter()
const logout = () => {
  logOut()
  store.commit('del_token')
  router.push({
    path: '/'
  })
}

const handleEdit = () => {
  // todo 调用编辑接口
}


const handleDelete = () => {
  // todo 调用删除接口
}

const tableData = (
    [{
      name: 'admin',
      phone: '11111111111',
      username: 'admin',
      password: '123456',
      date: '2022-12-16 11:23:11'
    }, {
      name: 'admin',
      phone: '11111111111',
      username: 'admin',
      password: '123456',
      date: '2022-12-16 11:23:11'
    }, {
      name: 'admin',
      phone: '11111111111',
      username: 'admin',
      password: '123456',
      date: '2022-12-16 11:23:11'
    }, {
      name: 'admin',
      phone: '11111111111',
      username: 'admin',
      password: '123456',
      date: '2022-12-16 11:23:11'
    }]
)

const input = ''

</script>


<style scoped>
.layout-container-demo .el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}

.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}

.layout-container-demo .el-menu {
  border-right: none;
}

.layout-container-demo .el-main {
  padding: 0;
}

.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>
